const express = require('express');
const router = express.Router();

router.get('/forServiceProperty', async(req, res, next) => {
    const options = {
        code: req.query.code,
        name: req.query.name,
        partCategoryId: req.query.partCategoryId,
        status: req.query.status,
        pageSize: req.query.pageSize,
        pageIndex: req.query.pageIndex,
        sortField: req.query.sortField,
        isDesc: req.query.isDesc
    };
    const data = {
        message: 'message',
        payload: {
            content: [
                {
                    id: 'id373',
                    code: 'code374',
                    name: 'name375',
                    description: 'description',
                    length: 1,
                    width: 1,
                    height: 1,
                    netWeight: 1,
                    grossWeight: 1,
                    unit: 'unit',
                    usagePerCar: 'usagePerCar',
                    minPackSize: 1,
                    partReplacementCode: 'partReplacementCode376',
                    status: 1,
                    rowVersion: 'rowVersion',
                    options: [
                        'update',
                        'batchCategory',
                    ]
                },
                {
                    id: 'id377',
                    code: 'code378',
                    name: 'name379',
                    description: 'description',
                    length: 1,
                    width: 1,
                    height: 1,
                    netWeight: 1,
                    grossWeight: 1,
                    unit: 'unit',
                    usagePerCar: 'usagePerCar',
                    minPackSize: 1,
                    partReplacementCode: 'partReplacementCode380',
                    status: 1,
                    rowVersion: 'rowVersion',
                    options: [
                        'update',
                        'batchCategory',
                    ]
                }
            ],
            pageIndex: null,
            pageSize: null,
            sort: null,
            totalElements: 50,
            totalPages: null
        }
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id 备件Id
 * @throws {Error}
 * @return {Promise}
 */
router.get('/:id/forServiceProperty', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message',
        payload: {
            id: 'id381',
            code: 'code382',
            name: 'name383',
            description: 'description',
            partCategoryName: 'partCategoryName',
            partCategoryCode: 'partCategoryCode',
            length: 1,
            width: 1,
            height: 1,
            netWeight: 1,
            grossWeight: 1,
            productCategoryCode: 'productCategoryCode384',
            partReplacementCode: 'partReplacementCode385',
            alternativePlan: 'alternativePlan',
            supplierCode: 'supplierCode386',
            unit: 'unit',
            certificationMark: 'certificationMark',
            minPackSize: 1,
            minOrderQuantity: 1,
            usagePerCar: 'usagePerCar',
            isConsume: true,
            isDecimalAllowed: true,
            overseaOnly: 'overseaOnly',
            shelfLife: 'shelfLife',
            safeMaterial: 'safeMaterial',
            packageRule: 'packageRule',
            isImported: true,
            remark: 'remark',
            status: 1,
            rowVersion: 'rowVersion',
            options: [
                'update',
                'batchCategory',
            ],
            partServiceProperties: [
                {
                    id: '1',
                    brandId: 'id1',
                    brandCode: 'code2',
                    brandName: 'name3',
                    dealerId: 'id4',
                    dealerCode: 'code5',
                    dealerName: 'name6',
                    partWarrantyCategoryId: 'id4',
                    partWarrantyCategoryCode: 'code5',
                    partWarrantyCategoryName: 'name6',
                    isPreAuthorized: true
                },
                {
                    id: '2',
                    brandId: 'id4',
                    brandCode: 'code5',
                    brandName: 'name6',
                    dealerId: 'id4',
                    dealerCode: 'code5',
                    dealerName: 'name6',
                    partWarrantyCategoryId: 'id4',
                    partWarrantyCategoryCode: 'code5',
                    partWarrantyCategoryName: 'name6',
                    isPreAuthorized: false
                }
            ],
            partServicePrices: [
                {
                    id: '1',
                    brandId: 'id1',
                    brandCode: 'code2',
                    brandName: 'name3',
                    year: 'year',
                    month: 'month',
                    currency: 1,
                    price: 1,
                    priceType: 1
                },
                {
                    id: '2',
                    brandId: 'id4',
                    brandCode: 'code5',
                    brandName: 'name6',
                    year: 'year',
                    month: 'month',
                    currency: 2,
                    price: 2,
                    priceType: 2
                }
            ],
            partDutyUnits: [
                {
                    dutyUnitId: 'dutyUnitId399',
                    dutyUnitCode: 'dutyUnitCode400',
                    dutyUnitName: 'dutyUnitName401',
                    isDefault: true
                },
                {
                    dutyUnitId: 'dutyUnitId402',
                    dutyUnitCode: 'dutyUnitCode403',
                    dutyUnitName: 'dutyUnitName404',
                    isDefault: false
                }
            ]
        }
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id 备件Id
 * @throws {Error}
 * @return {Promise}
 */
router.put('/:id/forServiceProperty', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @throws {Error}
 * @return {Promise}
 */
router.put('/batchCategory', async(req, res, next) => {
    const options = {
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
router.get('/forWorkItem', async(req, res, next) => {
    const options = {
        code: req.query.code,
        name: req.query.name,
        status: req.query.status,
        pageSize: req.query.pageSize,
        pageIndex: req.query.pageIndex,
        sortField: req.query.sortField,
        isDesc: req.query.isDesc
    };
    const data = {
        message: 'message',
        payload: {
            content: [
                {
                    id: 'id1754',
                    code: 'code1755',
                    name: 'name1756',
                    productCategoryCode: 'productCategoryCode1757',
                    minPackSize: 1,
                    minOrderQuantity: 1,
                    unit: 'unit',
                    usagePerCar: 'usagePerCar',
                    status: 1,
                    price: 1000
                },
                {
                    id: 'id1758',
                    code: 'code1759',
                    name: 'name1760',
                    productCategoryCode: 'productCategoryCode1761',
                    minPackSize: 1,
                    minOrderQuantity: 1,
                    unit: 'unit',
                    usagePerCar: 'usagePerCar',
                    status: 1,
                    price: 1000
                }
            ],
            pageIndex: null,
            pageSize: null,
            sort: null,
            totalElements: 50,
            totalPages: null
        }
    };
    res.json(data);
});
router.get('/forClaimApply', (req, res) => {
    const content = [];
    for(let i = 1; i <= 20; i++) content.push({
        id: `${i}`,
        code: `CODE${i}`,
        name: `NAME${i}`,
        wholeSalePrice: i < 4 ? (i * 10) - 1 : i * 1000,
        unit: '个'
    });

    res.json(
        {
            message: '',
            payload: {
                content,
                totalElements: 20,
            }
        }
    );
});

router.get('/forClaim', (req, res) => {
    const content = [];
    for(let i = 0; i < 5; i++)
        content.push({
            id: `2019${i}`,
            code: `code-2019-${i}`,
            name: `备件-2019-${i}`,
            productCategoryCode: `CX-2019-${i}`,
            unit: '件',
            minPackSize: i,
            price: i + 10,
            mgmtRate: 0.9,
            workItems: [
                {
                    id: `${i}`,
                    code: `workItemCode-${i}`,
                    name: `项目名称-${i}`,
                    laborHour: 1.5,
                    laborPrice: 100,
                    remark: 'string',
                    assistWorkItems: [
                        {
                            id: `${i}`,
                            code: `workItemCode-${i}`,
                            name: `项目名称-${i}`,
                            laborHour: 1.5,
                            laborPrice: 100,
                            remark: 'string',
                        }
                    ]
                }, {
                    id: `${i + 10}`,
                    code: `workItemCode-${i + 10}`,
                    name: `项目名称-${i + 10}`,
                    laborHour: 1.5,
                    laborPrice: 100,
                    remark: 'string'
                }
            ]
        });
    
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 5
        }
    });
});

router.get('/forExceptionInfoTransfer', (req, res) => {
    const content = [];
    for(let i = 0; i < 40; i++) content.push({
        id: `${i + 1}`,
        code: `code${i}`,
        name: `name${i}`,
        productCategoryCode: 'productCategoryCode',
        unit: 'unit',
        minPackSize: 1,
        price: 1,
    });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 40,
        }
    });
});

router.get('/forDealerServiceInformation', (req, res) => {
    const content = [];
    for(let i = 0; i < 5; i++)
        content.push({
            id: `00${i}`,
            code: `code${i}`,
            name: `name${i}`,
            supplierCode: `supplierCode${i}`,
            minPackSize: i,
            unit: 'unit',
            status: 1,
            partReplacementCode: `partReplacementCode${i}`,
        });
    
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 5
        }
    });
});
module.exports = router;
